Skip to content

Refactor PlanText parsing into PlanTextHelper; generate PlanText when editing plan hours on web#1570

Draft
Copilot wants to merge 2 commits into
stablefrom
copilot/refactor-googlesheethelper
Draft

Refactor PlanText parsing into PlanTextHelper; generate PlanText when editing plan hours on web#1570
Copilot wants to merge 2 commits into
stablefrom
copilot/refactor-googlesheethelper

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

When plan hours are edited via the web UI, PlanRegistration.PlanText was not updated to reflect the new shift times. The parsing logic for PlanText (format: HH:MM-HH:MM/break;...) was also duplicated across three files (~1300 lines of copy-paste).

New PlanTextHelper static class

  • ParsePlanText(PlanRegistration) — extracts shift start/end/break minutes from PlanText string (up to 5 shifts), recalculates PlanHours
  • GeneratePlanText(PlanRegistration) — reverse operation: generates PlanText from shift fields
  • BreakTimeCalculator / MinutesToBreakString — bidirectional break-time mapping
  • Round-trip invariant: Parse(Generate(reg)) produces bitwise-identical shift fields

Refactored callers

  • GoogleSheetHelper.cs — replaced two ~330-line duplicated parsing blocks with PlanTextHelper.ParsePlanText()
  • PlanRegistrationHelper.cs — same replacement for two more duplicated blocks

PlanText generation on web edits

  • TimePlanningPlanningService.Update() and UpdateByCurrentUserNam() now call GeneratePlanText() after setting shift fields:
planning.PlannedEndOfShift5 = model.PlannedEndOfShift5;
planning.PlanText = PlanTextHelper.GeneratePlanText(planning);

Tests

85 unit tests covering parsing, generation, break mapping, time formatting, and round-trip correctness.

…ith PlanTextHelper.ParsePlanText

Replace two large blocks of duplicated PlanText parsing logic (splitList + regex +
shift assignment + PlanHours calculation) with calls to PlanTextHelper.ParsePlanText().
Each block was ~340 lines of duplicated code reduced to 2 lines.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor GoogleSheetHelper and implement PlanText update for plan hours Refactor PlanText parsing into PlanTextHelper; generate PlanText when editing plan hours on web May 12, 2026
Copilot AI requested a review from renemadsen May 12, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When editing plan hours on web the planRegistration.PlanText needs to be updated accordingly

2 participants